import { Column, Entity, Unique } from 'typeorm';
import { BaseEntity } from '@app/common';
import { Expose } from 'class-transformer';

@Entity('system_user')
export class UserEntity extends BaseEntity {
  @Expose()
  @Column({ type: 'int', name: 'dept_id' })
  deptId: number;

  @Expose()
  @Column({ type: 'varchar', name: 'username' })
  username: string;

  @Expose()
  @Column({ type: 'varchar', name: 'password' })
  password: string;

  @Expose()
  @Column({ type: 'varchar', name: 'nickname' })
  nickName: string;

  @Expose()
  @Column({ type: 'varchar', name: 'avatar_url' })
  avatarUrl: string;

  @Expose()
  @Unique('phone', ['phone'])
  @Column({ type: 'varchar', name: 'phone' })
  phone: string;

  @Expose()
  @Unique('email', ['email'])
  @Column({ type: 'varchar', name: 'email' })
  email: string;

  @Expose()
  @Column({ type: 'varchar', name: 'last_login_ip' })
  lastLoginIp: string;

  @Expose()
  @Column({ type: 'timestamp', name: 'last_login_at' })
  lastLoginAt: Date;

  @Expose()
  @Column({ type: 'tinyint', name: 'status' })
  status: number;
}
